package com.ysstech.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 正则表达式
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum YssRegularEnum implements BaseEnum<String> {
    DATE_TIME_REGULAR("^(\\d{4})-([0-1]\\d)-([0-3]\\d)\\s([0-5]\\d):([0-5]\\d):([0-5]\\d)$", "yyyy-MM-dd HH:mm:ss日期格式字符串"),
    EMAIL_REGULAR("[a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-zA-Z0-9]+", "邮箱字符串");


    private final String code;
    private final String desc;

    public static YssRegularEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> b.code == code).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        YssRegularEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
